package com.test.web.controller;

import cn.hutool.json.JSONUtil;
import com.he.core.ResultT;
import com.test.web.bean.TestBean;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author heyanjing
 * date:2020-06-09 2020/6/9:22:54
 */
@Slf4j
@AllArgsConstructor
@RestController
public class ParamsController {

    @GetMapping("/params/get")
    public ResultT get(String a, String b) {

        log.info("-{}- -{}-", a, b);
        int i = 1 / 0;
        return ResultT.success();
    }

    @PostMapping("/params/post")
    public ResultT post(@Validated @RequestBody TestBean testBean, String a) {
        log.warn("-{}-", testBean.getStr());
        log.warn("{}", JSONUtil.toJsonStr(testBean));
        log.warn("{}", JSONUtil.toJsonStr(a));
        // int i = 1 / 0;
        return ResultT.successWithData(testBean);
    }

}
